home *** CD-ROM | disk | FTP | other *** search
- Path: EU.net!sun4nl!xs4all!jordan
- From: jordan@xs4all.nl (Jordan)
- Newsgroups: comp.lang.c
- Subject: Returning string from function (how?)
- Date: 30 Mar 1996 11:05:21 GMT
- Organization: XS4ALL Internet
- Message-ID: <4jj4hh$m9n@news.xs4all.nl>
- NNTP-Posting-Host: xs1.xs4all.nl
-
- Hi all, i'm trying to get a string returned from a function, but it's not
- working as i planed.
- Does anyone have some ideas?
-
-
- something like this, but then working ;)
-
- /*****************************************/
-
- char s;
-
- char get_str(void);
-
- main()
- {
- s = get_str();
-
- printf("%s", s);
- }
-
- char get_str(void)
- {
- int i;
- char ch, string;
-
- i=0;
- printf("Enter a string: ");
- while((ch = getchar()) != '\n' && i < MAX)
- string[i++] = ch;
- string[i] = '\0';
-
- return string;
- }
-
-
- Grtz Jordan
- --
- ---------------------------------------------jordan@dark4ce.xs4all.nl
- But what if you are lost on the Information Superhighway
- who do you ask for directions... (J.G. - Future Quest)
- ---------------------------------------------------------------------
-